//============================================================================
// Name        : material.cpp
// Author      : Benedikt Bovelette / Ingmar Hartung
// Version     :
// Copyright   : (c) 2012
// Description :
//============================================================================

#include "Header/allincludes.h"

void initMaterial(int i) {
	GLfloat globalAmbient[4] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat ambient[4] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat diffuse[4] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat specular[4] = { 0.0, 0.0, 0.0, 1.0 }; // reflexionsgrad
	GLfloat shiny = 0.0f;
	switch (i) {
	case 0: // kupfer
		ambient[0] = 0.19;
		ambient[1] = 0.07;
		ambient[2] = 0.02;
		ambient[3] = 1.0;
		diffuse[0] = 0.70;
		diffuse[1] = 0.27;
		diffuse[2] = 0.08;
		diffuse[3] = 1.0;
		specular[0] = 0.26;
		specular[1] = 0.14;
		specular[2] = 0.26;
		specular[3] = 1.0;
		shiny = 12.8f;
		break;
	case 1: // silber poliert
		ambient[0] = 0.23;
		ambient[1] = 0.23;
		ambient[2] = 0.23;
		ambient[3] = 1.0;
		diffuse[0] = 0.28;
		diffuse[1] = 0.28;
		diffuse[2] = 0.28;
		diffuse[3] = 1.0;
		specular[0] = 0.77;
		specular[1] = 0.77;
		specular[2] = 0.77;
		specular[3] = 1.0;
		shiny = 89.6f;
		break;
	case 2: // gold poliert
		ambient[0] = 0.25;
		ambient[1] = 0.22;
		ambient[2] = 0.06;
		ambient[3] = 1.0;
		diffuse[0] = 0.35;
		diffuse[1] = 0.31;
		diffuse[2] = 0.09;
		diffuse[3] = 1.0;
		specular[0] = 0.80;
		specular[1] = 0.72;
		specular[2] = 0.21;
		specular[3] = 1.0;
		shiny = 83.2f;
		break;
	case 3: // gold
		ambient[0] = 0.25;
		ambient[1] = 0.20;
		ambient[2] = 0.07;
		ambient[3] = 1.0;
		diffuse[0] = 0.75;
		diffuse[1] = 0.61;
		diffuse[2] = 0.23;
		diffuse[3] = 1.0;
		specular[0] = 0.63;
		specular[1] = 0.65;
		specular[2] = 0.37;
		specular[3] = 1.0;
		shiny = 51.8f;
		break;
	case 4: // chrom
		ambient[0] = 0.25;
		ambient[1] = 0.25;
		ambient[2] = 0.25;
		ambient[3] = 1.0;
		diffuse[0] = 0.40;
		diffuse[1] = 0.40;
		diffuse[2] = 0.40;
		diffuse[3] = 1.0;
		specular[0] = 0.77;
		specular[1] = 0.77;
		specular[2] = 0.77;
		specular[3] = 1.0;
		shiny = 76.8f;
		break;
	case 5: // Rubin
		ambient[0] = 0.17;
		ambient[1] = 0.01;
		ambient[2] = 0.01;
		ambient[3] = 0.5;
		diffuse[0] = 0.61;
		diffuse[1] = 0.04;
		diffuse[2] = 0.04;
		diffuse[3] = 0.5;
		specular[0] = 0.73;
		specular[1] = 0.63;
		specular[2] = 0.63;
		specular[3] = 0.5;
		shiny = 76.8;
		break;
	case 6: // Bovelette-Hartung Creature
		ambient[0] = 1.0;
		ambient[1] = 1.0;
		ambient[2] = 1.0;
		ambient[3] = 1.0;
		diffuse[0] = 1.0;
		diffuse[1] = 1.0;
		diffuse[2] = 1.0;
		diffuse[3] = 1.0;
		specular[0] = 1.0;
		specular[1] = 1.0;
		specular[2] =1.0;
		specular[3] = 1.0;
		shiny = 68.0;
		break;
	case 7: // Smarakt- Gruen
		ambient[0] = 0.02;
		ambient[1] = 0.17;
		ambient[2] = 0.02;
		ambient[3] = 0.5;
		diffuse[0] = 0.08;
		diffuse[1] = 0.61;
		diffuse[2] = 0.08;
		diffuse[3] = 0.5;
		specular[0] = 0.63;
		specular[1] = 0.73;
		specular[2] = 0.63;
		specular[3] = 0.5;
		shiny = 76.8;
		break;
	case 8: // Smarakt- Gruen very dark
		ambient[0] = 0.005;
		ambient[1] = 0.11;
		ambient[2] = 0.005;
		ambient[3] = 0.09;
		diffuse[0] = 0.02;
		diffuse[1] = 0.55;
		diffuse[2] = 0.02;
		diffuse[3] = 0.17;
		specular[0] = 0.57;
		specular[1] = 0.67;
		specular[2] = 0.55;
		specular[3] = 0.17;
		shiny = 76.8;
		break;
	case 9: // Smarakt- Gruen-very bright
		ambient[0] = 0.08;
		ambient[1] = 0.23;
		ambient[2] = 0.08;
		ambient[3] = 0.9;
		diffuse[0] = 0.14;
		diffuse[1] = 0.67;
		diffuse[2] = 0.14;
		diffuse[3] = 0.9;
		specular[0] = 0.69;
		specular[1] = 0.79;
		specular[2] = 0.69;
		specular[3] = 0.9;
		shiny = 76.8;
		break;
	case 10: // nix
		ambient[0] = 0;
		ambient[1] = 0;
		ambient[2] = 0;
		ambient[3] = 0;
		diffuse[0] = 0;
		diffuse[1] = 0;
		diffuse[2] = 0;
		diffuse[3] = 0;
		specular[0] = 0;
		specular[1] = 0;
		specular[2] = 0;
		specular[3] = 0;
		shiny = 0;
		break;
	default: // zinn
		ambient[0] = 0.11;
		ambient[1] = 0.06;
		ambient[2] = 0.11;
		ambient[3] = 1.0;
		diffuse[0] = 0.43;
		diffuse[1] = 0.47;
		diffuse[2] = 0.54;
		diffuse[3] = 1.0;
		specular[0] = 0.33;
		specular[1] = 0.33;
		specular[2] = 0.52;
		specular[3] = 1.0;
		shiny = 9.8f;
		break;
	}
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient);

	// Materialparameter setzen
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 51.2f); // kupfer = 12.8, silber poliert = 89.6, gold = 83.2, gold = 51.2
}

